package com.lyn.module_custom_utils.password;

import java.util.Random;

/**
 * @author:longyongning
 * @date:2021/10/2
 * @description:随机生成数字密码
 */
public class RandomUtil {

    private static Random random = new Random();


    public static String getRandomPassword(int length) {
        if (length == 0) {
            return null;
        }
        String sexStr = String.valueOf(System.currentTimeMillis());

        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int nextInt = random.nextInt(sexStr.length());
            stringBuffer.append(sexStr.substring(nextInt,nextInt+1));
        }
        return stringBuffer.toString();
    }
}

